<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name:{{ name }}</div>
    <div class="dashboard-text">roles:<span v-for="role in roles" :key="role">{{ role }}</span></div>
    <div class="dashboard-text">今日打卡状态:{{ reportStatus }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {getReportStatus} from "@/views2/api/dashboard";
import jwtDecode from "jwt-decode";
import {getToken} from "@/utils/auth";

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters({
      'name': 'name',
      'roles':'roles'
    })
  },
  mounted() {
    this.getReportStatus()
  },
  data(){
    return{
      reportStatus:"未打卡"
    }
  },
  methods:{

    getReportStatus()
    {
      getReportStatus(jwtDecode(getToken()).userId).then(res=>{

        console.log(res);
        let data=res.data;
        this.reportStatus=data.data.reportStatus===1?"已打卡":"未打卡"
      }).catch(err=>{
        popMessage(false,err,"error")
      })
    }

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
